Core.Random = function(seed)  {
	// LCG using GCC's constants
	this.m = 0x100000000; // 2**32;
	this.a = 1103515245;
	this.c = 12345;

	this.seed = seed;
	this.state = seed ? seed : Math.floor( Math.random( ) * (this.m - 1 ) );
};


Core.Random.prototype = {
		
	nextInt: function() {
		this.state = (this.a * this.state + this.c) % this.m;
		return this.state;
	},
	
	nextFloat: function() {
		return this.nextInt() / (this.m - 1);
	},
	
	nextRange: function(start, end) {
		
		var rangeSize, randomUnder;
		
		// returns in range [start, end): including start, excluding end
		// can't modulu nextInt because of weak randomness in lower bits
		rangeSize = end - start;
		randomUnder = this.nextInt() / this.m;
		
		return start + Math.floor(randomUnder * rangeSize);
	},
	
	choice: function(array) {
		return array[this.nextRange(0, array.length)];
	}
};